package com.cya.lotterysystem.dao.mapper;

import com.cya.lotterysystem.dao.dataobject.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author ：陈奕安（3048279304@qq.com）
 * @date ：Created in 2025/11/3 17:18
 * @description：
 * @modified By：
 * @version:
 */
@Mapper
public interface ActivityMapper  {

    @Insert("insert  into activity (activity_name,description,status) " +
            " values (#{activityName},#{description},#{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insrt(ActivityDO activityDO);


    @Select("select count(1) from activity")
    int count();

    @Select("select * from activity order by id desc  limit #{offset},#{pageSize}")
    List<ActivityDO> selectByActivityList(@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);


    @Select("select * from activity where id=#{id}")
    ActivityDO selectById(@Param("id") Long activityId);
@Select("select count(1) from activity_prize where activity_id=#{activityId} and status=#{status}")
    int countPrize(@Param("activityId") Long activityId, @Param("status") String status);

@Update("update activity set status =#{status} where id=#{activityId}")
    void updateStatus(@Param("activityId")Long activityId,@Param("status")  String status);
}